#include "Hud.h"

// Nothing to construct
Hud::Hud(void)
{
}

Hud::~Hud(void)
{
}

void Hud::loadTextures(){
	// Load the texture
	loadOpenGL2DTextureBMP("hud.bmp", &hudImage, GL_RGB);
}

void Hud::draw(Status *status){

	glDisable(GL_LIGHTING);

	glMatrixMode( GL_PROJECTION );
	glPushMatrix();  
	glLoadIdentity();
	// Switch the view modes to an Ortho style
	// this will allow us to see staight on what is rendered following.
	glOrtho( 0.0, 800, 0.0, 600, -1.0, 1.0 );
	glMatrixMode( GL_MODELVIEW );

	Time(status);
	Keys(status);
	Equip(status);
	CurrentEquip(status);
	PotatoLeft(status);

	glPushMatrix();
	glLoadIdentity();

	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, hudImage);

	glColor3f(1, 1, 1); 

	glBegin(GL_QUADS);

	// Draw the quad at the appropriate area
	// the Texture is drawn over it.
	glTexCoord2f(0.0f, 0.0f); glVertex3f(0, 0,  0);	// Bottom Left Of The Texture and Quad
	glTexCoord2f(1.0f, 0.0f); glVertex3f( 800, 0,  0);	// Bottom Right Of The Texture and Quad
	glTexCoord2f(1.0f, 1.0f); glVertex3f( 800,  70,  0);	// Top Right Of The Texture and Quad
	glTexCoord2f(0.0f, 1.0f); glVertex3f(0,  70,  0);	// Top Left Of The Texture and Quad

	glEnd();	

	glDisable(GL_TEXTURE_2D);

	//Unsets Projection Mode
	glMatrixMode( GL_PROJECTION );
	glPopMatrix();  
	glMatrixMode( GL_MODELVIEW );
	glPopMatrix(); 

	glEnable(GL_LIGHTING);
}

void Hud::Time(Status *status)
{

	int counter = 0;
	char s [33];
	_itoa(status->getCountdown(), s, 10);

	glPushMatrix();    
	glLoadIdentity();

	glColor3f(0.0, 0.0, 0.0); 
	glTranslatef(25, 25, 0);
	glScalef(.2, .2, 0);

	glutStrokeCharacter(GLUT_STROKE_ROMAN,'T');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'i');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'m');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'e');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,':');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,s[0]);
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,s[1]);
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,s[2]);
	glTranslatef(-counter, 0, 0);

	glScalef(1/.2,1/.2,0);
	glPopMatrix();

}

void Hud::Equip(Status *status)
{
	int counter = 0;

	glPushMatrix();    
	glLoadIdentity();

	glColor3f(0.0, 0.0, 0.0); 
	glTranslatef(200, 30, 0);
	glScalef(.1, .1, 0);

	glutStrokeCharacter(GLUT_STROKE_ROMAN,'E');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'q');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'u');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'i');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'p');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,':');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,' ');

	if (status->hasEquip(ICESKATES))
	{
		glColor3f(0.0, 0.0, 0.0);

		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'(');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'3');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,')');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'-');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'I');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'c');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'e');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,' ');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'S');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'k');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'a');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'t');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'e');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'s');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,' ');

		glColor3f(1.0, 1.0, 1.0);
	}

	if (status->hasEquip(FIREBOOTS))
	{
		glColor3f(0.0, 0.0, 0.0);

		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'(');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'1');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,')');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'-');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'F');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'i');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'r');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'e');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,' ');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'B');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'o');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'o');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'t');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'s');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,' ');

		glColor3f(1.0, 1.0, 1.0);
	}

	glTranslatef(-counter, 0, 0);

	glScalef(1/.1,1/.1,0);
	glPopMatrix();

}

void Hud::Keys(Status *status)
{
	int counter = 0;

	glPushMatrix();    
	glLoadIdentity();

	glColor3f(0.0, 0.0, 0.0); 
	glTranslatef(200, 50, 0);
	glScalef(.1, .1, 0);

	glutStrokeCharacter(GLUT_STROKE_ROMAN,'K');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'e');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'y');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'s');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,':');

	if (status->hasKey(RED))
	{
		glColor3f(1.0, 0.0, 0.0);

		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'R');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'e');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'d');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,' ');
		glColor3f(1.0, 1.0, 1.0);
	}
	if (status->hasKey(YELLOW))
	{
		glColor3f(1.0, 1.0, 0.0);

		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'Y');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'e');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'l');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'l');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'o');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'w');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,' ');
		glColor3f(1.0, 1.0, 1.0);
	}
	if (status->hasKey(ORANGE))
	{
		glColor3f(1.0, 0.5, 0.0);

		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'O');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'r');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'a');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'n');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'g');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'e');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,' ');
		glColor3f(1.0, 1.0, 1.0);
	}
	if (status->hasKey(GREEN))
	{
		glColor3f(0.0, 1.0, 0.0);

		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'G');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'r');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'e');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'e');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'n');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,' ');
		glColor3f(1.0, 1.0, 1.0);
	}

	glTranslatef(-counter, 0, 0);

	glScalef(1/.1,1/.1,0);
	glPopMatrix();

}

void Hud::CurrentEquip(Status *status)
{
	int counter = 0;

	glPushMatrix();    
	glLoadIdentity();

	glColor3f(0.0, 0.0, 0.0); 
	glTranslatef(600, 50, 0);

	glScalef(.1, .1, 0);

	glutStrokeCharacter(GLUT_STROKE_ROMAN,'C');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'u');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'r');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'r');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'e');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'n');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'t');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,' ');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'E');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'q');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'u');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'i');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'p');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,':');
	glTranslatef(-counter*3, 0, 0);
	glScalef(1/.1, 1/.1, 0);

	counter = 0;
	glTranslatef(0, -20, 0);
	glScalef(.1, .1, 0);

	if (status->getCurrentEquip() == ICESKATES)
	{
		glColor3f(0.0, 0.0, 0.0);

		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'I');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'c');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'e');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,' ');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'S');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'k');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'a');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'t');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'e');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'s');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,' ');

		glColor3f(1.0, 1.0, 1.0);
	}

	if (status->getCurrentEquip() == FIREBOOTS)
	{
		glColor3f(0.0, 0.0, 0.0);

		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'F');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'i');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'r');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'e');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,' ');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'B');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'o');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'o');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'t');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,'s');
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,' ');

		glColor3f(1.0, 1.0, 1.0);
	}

	glTranslatef(-counter, 0, 0);

	glScalef(1/.1,1/.1,0);
	glPopMatrix();

}

void Hud::PotatoLeft(Status *status)
{
	int counter = 0;

	char s [10];
	int i = 0;

	for (i = 0 ; i < 10 ; i++)
		s [i] = ' ';

	_itoa(status->potatosLeft(), s, 10);

	glPushMatrix();    
	glLoadIdentity();

	glColor3f(0.0, 0.0, 0.0); 
	glTranslatef(200, 10, 0);
	glScalef(.1, .1, 0);

	glutStrokeCharacter(GLUT_STROKE_ROMAN,'P');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'o');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'t');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'a');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'t');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'o');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'s');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,' ');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'L');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'e');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'f');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,'t');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,':');
	counter += 30;
	glTranslatef(30, 0, 0);
	glutStrokeCharacter(GLUT_STROKE_ROMAN,' ');

	for ( i = 0 ; i < 10 ; i++ )
	{
		counter += 30;
		glTranslatef(30, 0, 0);
		glutStrokeCharacter(GLUT_STROKE_ROMAN,s[i]);
	}

	glTranslatef(-counter, 0, 0);

	glScalef(1/.1,1/.1,0);
	glPopMatrix();

}